<?php
@include_once("commonFunctions.php");

?>
<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" type="text/css" href="CSS/formStyle.css" />
        <script type="text/javascript" src="JavaScript/showTickets_ajax.js"></script>
        <title>TTS - Viewing Trouble Tickets</title>
    </head>
    <body onload="disable(); ">
        <div id="logo">
		<img src="logo.png" />
   	</div>
    	<div id="menu">
		<a href="index.php" class="menuitem">Login</a>
		<a href="main.php" class="menuitem">View Tickets</a>
		<a href="submitNewTT.php" class="menuitem">Submit New Ticket</a>
		<p id="districtname">South Georgia</p>
    	</div>
	<div id="infobox" class="gradient">
		<div id="infotext">
			<h3>Ticket info</h3>
			<p>This page displays specific information about a trouble ticket.</p>
		</div>
	</div>
        <div id="header">
            <?php tts_getheader(); ?>
        </div>
        <a href="javascript:history.go(-1)" class="goback">Go Back</a>
        <?php
            if (!isset($_GET['MAView'])) {
                $tts = tts_getAllTTOfStatus($_GET['status'], $dealer->dealerCode);
            } else if (isset($_GET['MAView'])) {
                $query = 'select id from tt where assignedTo =\'' . $dealer->dealerCode . '\' and currentStatus = \'' . ($_GET['status']) . '\'';
                $result = mysql_query($query) or die('getHeader.php: Failed while getting count of Unresolved tickets');
                $tts = array();
                while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                    array_push($tts, (new TT($row['id'])));
                }
            }

            echo '<div id="troubleticketview">';
            tts_getTicketHeader();
            for ($i = 0; $i < sizeof($tts); $i++) {
                tts_getTicketTR($tts[$i]->id);
            }
            echo '</table></div>';
        ?>
    </body>
</html>
